import { MongooseFactory } from '../kalend';
import * as Mongoose from 'mongoose';
import { Schema } from 'mongoose';

const schema = MongooseFactory.Schema({

    /** 对应 Controller 的值 */
    key: {
        type: String,
        required: true,
        unique: true
    },
    parent: {
        type: Mongoose.Schema.Types.ObjectId,
        ref: "menu",
        default: null
    },
    /** 资源节点名称 */
    name: {
        type: String,
        required: true
    },
    /** 层级 */
    level: {
        type: Number,
        default: 0
    },
    /** 图标 */
    icon: String,
    url: {
        type: String
    },
    /** 备注信息 */
    description: String,
    order: Number
});

/**菜单树模型 */
export const menuModel = MongooseFactory.Model("menu", schema);